<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="">
              <a-input placeholder="请输入入库单编号" v-model="queryParam.queryName"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-select v-model="queryParam.queryCode" ref="select" placeholder="状态">
              <a-select-option value="0">待入库</a-select-option>
              <a-select-option value="1">入库中</a-select-option>
              <a-select-option value="2">已入库</a-select-option>
            </a-select>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" style="color: #F9D532;width: 80px;height: 36px;background: #333333;border-style: none;">查询</a-button>
              <a-button type="primary" @click="searchReset" style="margin-left: 8px;width: 80px;height: 36px;background: #eae7e7;border-style: none;color: #323232">重置</a-button>
            </span>
          </a-col>

          <a-button type="primary" @click="increase_data(0)" icon="plus" style="color: #F9D532;width: 120px;height: 36px;background: #333333;border-style: none;float: right;margin-right: 16px;">新增入库单</a-button>
        </a-row>
      </a-form>
    </div>

    <div style="background: #f2f2f2;height: 5px;width: auto;margin-top: 8px;margin-bottom: 20px;"></div>

    <div>
      <div style="border: none;background-color: #ffffff;padding-bottom: 28px;">
        <span style="font-size: 16px;float: left;color:#000000;font-weight: bold;margin-bottom: 10px">入库单列表</span>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange" style="margin-top: -20px;">

        <template slot="avatarslot" slot-scope="text, record, index">
          <div class="anty-img-wrap">
            <a-avatar shape="square" :src="getAvatarView(record.img)" icon="img"/>
          </div>
        </template>

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <div align="center" style="align-content: center;margin-left: 0px;">
           <a @click="continue_fill(record.id)" style="float: left;margin-left: 12px;font-size: 14px;color: #d29328;" v-show="record.status!=2">继续填写</a>
          <a @click="set_reservoir(record.id)" style="float: left;margin-left: 12px;font-size: 14px;color: #d29328;">查看详情</a>
          </div>
        </span>
      </a-table>
    </div>

<!--    <AddwarehouseModule ref="modalForm" @ok="modalFormOk"></AddwarehouseModule>-->
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {putAction,postAction,getFileAccessHttpUrl,httpAction} from '@/api/manage';
  import JDate from '@/components/jeecg/JDate.vue'
  import '@/assets/less/TableExpand.less'
  // import AddwarehouseModule from './modules/AddwarehouseModule'

  export default {
    name: "categoryinfo",
    mixins:[JeecgListMixin],
    components: {
      JDate
    },
    data () {
      return {
        description: 'categoryinfo管理页面',
        tabs: 1,//切换框
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'入库单编号',
            align:"center",
            dataIndex: 'code'
          },
          {
            title:'创建时间',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title:'商品数量',
            align:"center",
            dataIndex: 'sumCount'
          },
          {
            title:'入库总金额',
            align:"center",
            dataIndex: 'sumMoney'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'status',
            customRender:function (text) {
              if(text=='0'){
                return "待入库"
              }else if(text=='1'){
                return "入库中"
              }else if(text=='2'){
                return "已入库"
              }
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            width: 200,
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/inventory/manger/instorageDanPagelist",
          add_instorageDan:"/inventory/manger/add_instorageDan",
          delete_leibie: "/admin/parameter/delete_category"
        }
      }
    },
    methods: {
      getAvatarView: function (avatar) {
        return getFileAccessHttpUrl(avatar)
      },
      increase_data(record) {
        postAction(this.url.add_instorageDan).then((res)=>{
          // console.log(res)
          if(res.code=='0'){
            this.$router.push({path:'/create/rukudan',query: {rukudan_id:res.instorageDanId}})
          }else {
            this.$message.error(res.msg);
          }
        });
      },
      set_reservoir(cangku_id){//查看详情
        this.$router.push({path:'/see/rukudanDetail',query: {rukudan_id:cangku_id}})
      },
      continue_fill(rukudan_id){//继续填写
        this.$router.push({path:'/create/rukudan',query: {rukudan_id:rukudan_id}})
      },
      delete_plate(id){
        let params = {canshu_id:id};
        httpAction(this.url.delete_leibie,params,"put").then((res)=>{
          if(res.success){
            this.$message.success(res.message);
            this.loadData();
          }else {
            this.$message.error(res.message);
          }
        });
      },
      edit_category_status(id,status){//修改类别的状态
        let params = {category_id:id,status:status};
        httpAction(this.url.edit_cate_staus,params,"put").then((res)=>{
          if(res.success){
            this.$message.success(res.message);
            this.loadData();
          }else {
            this.$message.error(res.message);
          }
        });
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>